﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<title></title>
<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1><spring:message code="message.listForm.yaoPinMuLu"/><spring:message code="message.jqGrid.cz.xiangQing"/></h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.lable.StdManage"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.lable.drugcatalogStd"/></a></li>
        </ol>
    </section>
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
	            <form  action="${ctx}/stdDrugcatalog/exportExcel.html" id="exportExcel" method="post">
		            <input id="fileName" name="fileName" type="hidden" value="${fileName}" />
		            <input type="hidden" name="drugcatalogId" value="${drugcatalogId}"/> 
		            <input type="hidden" name="drugcatalogName" value="${Name}"/> 
		            <div class="input">
		                  <div class="textalign1"><spring:message code="message.listForm.fenLeiMingCheng"/>：</div>
		                    <div class="boxinput">
		                        <input type="text" class="textinput" id="qualityspecClass" name="qualityspecClass" placeholder="<spring:message code="message.listForm.fenLeiMingCheng"/>"/>
		                    </div>
		                  <div class="textalign"><spring:message code="message.listForm.pinZhongXuHao"/>：</div>
		                    <div class="boxinput">
		                        <input type="text" class="textinput" id="qualityspecIndex" name="qualityspecIndex" placeholder="<spring:message code="message.listForm.pinZhongXuHao"/>"/>
		                    </div>
		                  <div class="textalign"><spring:message code="message.listForm.tongYongMing"/>：</div>
		                    <div class="boxinput">
		                        <input type="text" class="textinput" id="qualityspecName" name="qualityspecName" placeholder="<spring:message code="message.listForm.tongYongMing"/>"/>
		                    </div>
		            </div> 
		            <div class="input">
		                  <div class="textalign1"><spring:message code="message.lable.status"/>：</div>
		                    <div class="boxinput">
		                         <select class="textinput" name="status" id="status">
		                            <option value=""><spring:message code="message.select.option"/></option>
		                            <option value="1"><spring:message code="message.button.start"/></option>
		                            <option value="2"><spring:message code="message.button.stop"/></option>
		                         </select>
		                     </div>
		                   <div class="textalign" >
		                        <input id="selectDicCompType" type="button" onclick="likeQuery();" class="btn btn-success btn-sm" value="<spring:message code="message.button.seachSpacing"/>">
		                   </div> 
		            </div> 
	           </form>
            </div>
        </div>
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
        <div class=" box box-warning bottongroup">
            <a  class="btn btn-default btn-sm" href="${ctx}/stdDrugcatalog/toStdDrugcatalogDetailInfoAdd.html?drugcatalogId=${drugcatalogId}&drugcatalogName=${Name}" ><spring:message code="message.button.addDetail"/></a>
            <a  class="btn btn-default btn-sm" href="javascript:changeStatus(1);" ><spring:message code="message.button.startSpacing"/></a>
            <a  class="btn btn-default btn-sm" href="javascript:changeStatus(2);" ><spring:message code="message.button.stopSpacing"/></a>
        	<label onclick="exportExcel();" class="btn btn-default btn-sm"><spring:message code="message.lable.daoChu"/></label>
        <a href="${ctx }/stdDrugcatalog/list.html"  class="btn btn-default btn-sm"><spring:message code="message.button.getBackSpacing"/></a>
        </div>
        <!-- 弹出编辑框 -->
        <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                     <div class="modal-header bg-primary">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h5 class="modal-title" id="exampleModalLabel"><spring:message code="message.lable.drugcatalogSTDedit"/></h5>
                    </div>
                    <div class="modal-body">
                  <form id="formSubmit"  action="saveOrEditDrugQualitySpec.html">
                    <div class="form-group form-group-xs">
                        <label for="recipient-name" class=" control-label"><spring:message code="message.listForm.fenLeiMingCheng"/>：</label>
                        <div class="">
                            <input type="text" class="form-control"  id="qualityspecClass1" placeholder="<spring:message code="message.listForm.fenLeiMingCheng"/>" name="qualitySpecCode" >
                        </div>
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="recipient-name" class=" control-label"><spring:message code="message.listForm.pinZhongXuHao"/>：</label>
                        <input type="text" class="form-control" id="qualityspecIndex1" name="qualitySpecName" placeholder="<spring:message code="message.listForm.pinGuiMingCheng"/>">
                    </div>
                    <input type="hidden" id="drugCataId"> 
                </form>
                    </div>
              <div class="modal-footer">
              <input hidden="true" id="spid"/>
              <input hidden="true" id="spfatherid"/>
                  <button type="button" onclick="save();" class="btn btn-primary btn-sm"><spring:message code="message.button.saveSpacing"/></button>
                  <button type="button" class="btn btn-danger btn-sm" data-dismiss="modal"><spring:message code="message.button.closeSpacing"/></button>
              </div>
            </div>
         </div>
      </div>
      <!-- 弹出编辑框 -->
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">
    
    //绑定回车
    $('#qualityspecClass,#qualityspecIndex,#qualityspecName,#status').bind('keydown', function(event) {
        if (event.keyCode == "13") {        //13 位电脑上回车键的位置代码
            $('#selectDicCompType').click();
        }
    }); 
  
    $("#qualityspecClass").focus();//加载页面光标在第一个查询框内
    
        $(function () {
            $("#gridlist").jqGrid({
                url: "getStdDrugcatalogDetailInfo.html?drugcatalogId=${drugcatalogId}",
                mtype: "POST",
                datatype: "json",
                autowidth: true,
                height: 270,                    
                colNames: ['<spring:message code="message.jqGrid.cz"/>',
                           '<spring:message code="message.listForm.yaoPin"/>id',
                           '<spring:message code="message.listForm.yaoPin"/><spring:message code="message.listForm.pinGui"/>id',
                           '<spring:message code="message.listForm.fenLeiMingCheng"/>',
                           '<spring:message code="message.listForm.pinZhongXuHao"/>',
                           '<spring:message code="message.listForm.yaoPinBianMa"/>',
                           '<spring:message code="message.listForm.tongYongMing"/>',
                           '<spring:message code="message.listForm.jiXing"/>',
                           '<spring:message code="message.listForm.guiGe"/>',
                           '<spring:message code="message.lable.status"/>'
                           ],
                colModel: [
                        { name: 'operate', width: "10%",align: 'center',sortable: false,
                            formatter : function(val, opts, rowdata) {
                                var str="";
                                str +=  "<a href=\"javascript:edit('"+rowdata.qualityspecClass+"','"+rowdata.qualityspecIndex+"','"+rowdata.drugCataId+"');\" style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat 0px 0px' class='opIcon' title='<spring:message code="message.jqGrid.cz.bianJi"/>'></a>";
                                return str;
                        }},
                        { name: 'qualityspecId',hidden:true, width: "0%",align: 'center',sortable: false},
                        { name: 'drugCataId',hidden:true, width: "0%",align: 'center',sortable: false}, 
                        { name: 'qualityspecClass', width: "20%",align: 'center',sortable: false},
                        { name: 'qualityspecIndex', width: "20%",align: 'center',sortable: false},
                        { name: 'qualityspecCode', width: "0%",hidden:true, align: 'center',sortable: false},
                        { name: 'qualityspecName', width: "20%",align: 'center' ,sortable: false},
                        { name: 'formName', width: "20%",align: 'center',sortable: false},
                        { name: 'specName', width: "20%",align: 'center',sortable: false},
                        { name: 'status', width: "10%", align: 'center',sortable: false,
                            formatter : function(val, opts, rowdata) {
                                if(val==1){
                                    return "<spring:message code="message.button.start"></spring:message>";
                                }else if(val==2){
                                    return "<span class='red'><spring:message code="message.button.stop"></spring:message></span>";
                                }
                            } 
                        },
                    
                ],
                rowNum: 20,
                rowList: [10, 20, 50,100],
                rownumbers: true,
                multiselect: true, 
                pager: "#gridpage",
                viewrecords: true,
                caption: "<spring:message code="message.list.drugcatalogStdDetaillist"/>",
                gridComplete: function(){
                 autoRNWidth("gridlist");
                    selectByOneData("gridlist");
               },
                jsonReader: {
                    repeatitems: false,
                    id: "drugCataId"
                }
            
            });
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");
        });
        
        function edit(qualityspecClass,qualityspecIndex,drugCataId){
               $("#drugCataId").val(drugCataId);
               $("#qualityspecClass1").val(qualityspecClass);
               $("#qualityspecIndex1").val(qualityspecIndex);
               $('#exampleModal').modal({
                     keyboard: true
               });
        }
        function changeStatus(status){
            var msg = "<spring:message code="message.button.stop"/>";
            if (status == 1) {
                var msg = "<spring:message code="message.button.start"/>";
            }
            var infos = batchSwitchStatus("gridlist","qualityspecName","status",msg,"<spring:message code="message.listForm.yaoPin"/>");
            if (infos.length <= 1) {
                return;
            }
            
            $.HN.message.confirm('<spring:message code='message.button.confirm' />'+msg+'<spring:message code="message.lable.yiXia"/>'+infos[0].split(",").length+'<spring:message code="message.lable.tiao"/><spring:message code="message.listForm.yaoPin"/><spring:message code="message.lable.ma"/><br/>'+infos[1].replace(/\,/g,"<br/>"), '', '').on(function (e) {
                    if (e) {
                        $.ajax({
                            url: "${ctx}/stdDrugcatalog/changeStatus.html",//action地址
                            data: { state:status,param:infos[0] },//传值
                            type: "post",//执行方式get or post 默认以post方式执行
                            dataType:"json",
                            success: function (result) {//执行成功后 提示
                                if (result.success){
                                	top.$.HN.message.alert("<spring:message code='message.HN.alert.chengGong'/>"+msg+infos[0].split(",").length+"<spring:message code='message.lable.tiao'/><spring:message code='message.listForm.yaoPin'/><spring:message code='message.yanZheng.ganTanHao'/>","", "success");
                                    likeQuery($("#gridlist").getGridParam("page"));
                               } else {
                                   top.$.HN.message.alert("<spring:message code='message.HN.alert.fail' />！", "","error");
                               } 
                            }
                        });
                    }
                });
        }
        function save(){
        	$.HN.message.confirm('<spring:message code="message.HN.alert.OkSaveYESorNO"/>', '', '').on(function(e) {
        		 var qualityspecClass1 = $("#qualityspecClass1").val();
                 var qualityspecIndex1 = $("#qualityspecIndex1").val();
                 var drugCataId = $("#drugCataId").val();
                 $.ajax({
                     type: "POST",
                     url: "${ctx}/stdDrugcatalog/saveStdDrugCatalogDetail.html",
                     data:{
                         qualityspecClass:qualityspecClass1,
                         qualityspecIndex:qualityspecIndex1,
                          drugCataId:drugCataId
                     },
                     dataType:"json",
                     success: function(result){
                         if(result.success){
                             top.$.HN.message.alert(result.msg,"", 'success');
                             $("#gridlist").jqGrid('setGridParam',{page:1}).trigger("reloadGrid");
                             $('#exampleModal').modal('hide');
                         }else{
                             top.$.HN.message.alert(result.msg,"", 'error');
                                 }
                             }
                      });
        	});
           
        }
       function likeQuery(){
            var data  = formatForm("exportExcel");
            $("#gridlist").jqGrid('setGridParam', {
                mtype:"post",
                postData:data,
                page: 1 
           }).trigger("reloadGrid");
       }
        
        function exportExcel(){
    		$.HN.message.confirm('<spring:message code="message.lable.OKExport"/>&nbsp;${fileName}&nbsp;<spring:message code="message.lable.ma"/>', '', '').on(function (e) {
	               if (e) {
	            		  $("#exportExcel").submit();
			
	               }
         	 }); 
         	
    	} 
    </script>
</body>
</html>